<%
    Users user = Trader.getUser(request.getParameter("uid"));
	wstrader.task.trade.physical.Contract task = user.trade.physical.contract;
	if (!user.Authenticated()) {
		response.sendRedirect("logon.jsp");
		return;
	}
	((Tasks)task.getOwner()).clearFocus();
	task.setFocus(true);	
	Trader.window_width = "90%";	
	ResultSet rs;
%>

<%@include file="../header.jsp"%>

<%
	//long focused_id = task.doTask();
	//if (focused_id <= 0) focused_id = 1;
	//Record rc   = task.getRecord("purchase_contract",focused_id);
%>

<link href="style.css" rel="stylesheet" type="text/css">

<script language="javascript">
function doFilter()
{
	var form = document.formMain;
	form.action = "trade.physical.contract.jsp";
	form.submit();
}

function clickCardView(row)
{
	var form = document.formMain;
	if (row == null) row = old_row_obj;
	var vlen = row.id.length;
	var type = row.id.substring(0,1);
	if (type=="P")
	{
		form.type.value = "P";
		form.action = "trade.physical.contract.purchase.card.jsp";
	}
	else
	{
		form.type.value = "S";
		form.action = "trade.physical.contract.sales.card.jsp";
	}	
	form.submit();	
}

</script>
<style type="text/css">
<!--
.style3 {font-family: Arial}
.style6 {font-size: 12px}
-->
</style>
<form action="" method="post" name="formMain" id="formMain">
  <table width="100%"  border="0" cellspacing="0" cellpadding="0">
    <tr>
      <th colspan="2" align="left" scope="col"><img src="images/contracts.jpg" width="250" height="30"></th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
      <th colspan="4" scope="col"><input type="hidden" name="uid"        id="uid"       value="<%=user.getuid()%>">
        <input type="hidden" name="task_id"    id = "task_id"   value="0">
        <input name="type" type="hidden" id="type"></th>
    </tr>
    <tr align="left">
      <td colspan="8">
	    <table>
    <tr>
      <td width="150" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Contract Type </span></strong></td>
      <td width="150" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Origin</span></strong></td>
      <td align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Grade</span></strong></td>
      <td align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Buyer/Seller</span></strong></td>
      <td align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Last Date </span></strong></td>
    </tr>
    <tr>
      <td height="32">
	  <select name="cnt_type" size="9" id="cnt_type" onChange="doFilter()" style="font-family:Arial; font-size:11px; width:150px;border:0">
        <option value="0" selected>All</option>
        <option value="P">PURCHASE</option>
        <option value="S">SALES</option>
		<%task.getResponse().setSelected("cnt_type");%>
      </select>
	  </td>
      <td>
	  <select name="origin_id" size="9" id="origin_id" onChange="doFilter()" style="font-family:Arial; font-size:11px; width:150px;border:0">
		  <option value="0" selected>All</option>
	  	<%
			task.getResponse().setOption("origin_master","name");
			task.getResponse().setSelected("origin_id");
		%>	  
      </select>
	  </td>
      <td>
	  <select name="grade_id" size="9" id="grade_id" onChange="doFilter()" style="font-family:Arial; font-size:11px; width:160px;border:0">
	  	<option value="0" selected>All</option>
	  	<%
			task.getResponse().setOption("grade_master","name");
			task.getResponse().setSelected("grade_id");
		%>      
	  </select>
	  </td>
      <td>
	  <select name="buyer_seller" size="9" id="buyer_seller" onChange="doFilter()" style="font-family:Arial; font-size:11px; width:150px;border:0">
		  <option value="0" selected>All</option>
	  	<%
			task.getResponse().setOption(task.getBuyerSellerList());
			task.getResponse().setSelected("buyer_seller");
		%>	  
      </select>
	  </td>
      <td>
	  <select name="last_date" size="9" id="last_date" onChange="doFilter()" style="font-family:Arial; font-size:11px; width:150px;border:0">
		<%@include file="include/ContractLsDateList.jsp"%>
      </select>
	  </td>
    </tr>
	  
	  </table>	  </td>
    </tr>
    <tr>
      <td colspan="8">	  <table width="100%"  border="1" cellspacing="1" cellpadding="1">
        <tr bordercolor="#EEEEEE">
          <td width="4%" rowspan="2" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">&nbsp;</span></strong><strong><span class="style29 style3 style6">Id</span></strong></td>
          <td width="8%" rowspan="2" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">&nbsp;</span></strong><strong><span class="style29 style3 style6">Pur.Ref.No</span></strong></td>
          <td width="6%" rowspan="2" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">&nbsp;</span></strong><strong><span class="style29 style3 style6">Origin</span></strong></td>
          <td width="19%" rowspan="2" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">&nbsp;</span></strong><strong><span class="style29 style3 style6">Grade</span></strong></td>
          <td width="13%" rowspan="2" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">&nbsp;</span></strong><strong><span class="style29 style3 style6">Supplier</span></strong></td>
          <td colspan="2" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">&nbsp;</span></strong><strong><span class="style29 style3 style6">Shipping Period &nbsp;</span></strong></td>
          <td width="6%" rowspan="2" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">&nbsp;</span></strong><strong><span class="style29 style3 style6">Total</span></strong></td>
          <td width="8%" rowspan="2" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">&nbsp;</span></strong><strong><span class="style29 style3 style6">&nbsp;Deliverd</span></strong></td>
          <td width="6%" rowspan="2" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">&nbsp;</span></strong><strong><span class="style29 style3 style6">Balance&nbsp;</span></strong></td>
          <td colspan="2" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Basis Price </span></strong><strong><span class="style29 style3 style6"></span></strong></td>
        </tr>
        <tr bordercolor="#FFFBF0">
          <td width="8%" align="center" bordercolor="#EEEEEE" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">First Dt. </span></strong></td>
          <td width="8%" align="center" bordercolor="#EEEEEE" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Last Dt. </span></strong></td>
          <td width="7%" align="center" bordercolor="#EEEEEE" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Outright</span></strong></td>
          <td width="7%" align="center" bordercolor="#EEEEEE" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Diff</span></strong></td>
        </tr>
        <tr>
          <td colspan="12">
            <div id=scroll1 style="BORDER:0px ; OVERFLOW: auto; WIDTH: 100%; HEIGHT: 260px;">
              <%@include file="trade.physical.contract.list.details.jsp"%>
          </div></td>
        </tr>
      </table></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td align="right">&nbsp;&nbsp;</td>
      <td align="right">&nbsp;</td>
      <td align="right">&nbsp;</td>
      <td align="center">&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td align="right" valign="middle">&nbsp;&nbsp;</td>
      <td align="right" valign="middle">&nbsp;</td>
      <td align="right" valign="middle">&nbsp;</td>
      <td align="center" valign="middle"><img src="images/cardview.jpg" width="55" height="18" onClick="clickCardView();"></td>
    </tr>
  </table>
</form>
<%@include file="../footer.jsp"%>

